Skip to content

Conversation

dannyp32
Copy link
Contributor

@dannyp32 dannyp32 commented Aug 9, 2025

Fixes the following issue where a table will not be rendered if there isn't an extra line before the table.
#818

For example this will not render correctly

Here is the table:
| Key   | Value    |
| ----  | -------- |
| Color | Blue     |
| Size  | Medium   |

But this will because there's an extra new line before the table starts

Here is the table:

| Key   | Value    |
| ----  | -------- |
| Color | Blue     |
| Size  | Medium   |

Not handled in this change - whitespace between the new line and the pipe

@dannyp32
Copy link
Contributor Author

@xoofx hoping you can take a look. Open to any suggestions

@xoofx xoofx merged commit c436465 into xoofx:master Aug 28, 2025
1 check passed
@xoofx
Copy link
Owner

xoofx commented Aug 28, 2025

Thanks for this. I will have to double check some stuffs but it could be enough.

@RickStrahl
Copy link
Contributor

Checking in 0.42.0 - looks like this works for Grid Tables but not for Pipe Tables.

image

@MihaZupan
Copy link
Collaborator

Possibly an issue with how we're dealing with new lines in this change.
The PR added tests for a\r|... and a\n|... - if I change that to \r\n instead it fails.

@MihaZupan
Copy link
Collaborator

Looks like this change is also removing the content before the table

string md =
    """
    Some text
    | A |
    |---|
    | B |
    """.ReplaceLineEndings("\n");
    
var pipeline = new MarkdownPipelineBuilder()
    .UsePipeTables()
    .Build();

Console.WriteLine(Markdown.ToHtml(md, pipeline));

(note the missing "some text")

<table>
<thead>
<tr>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>B</td>
</tr>
</tbody>
</table>

And it doesn't match the table if the text before it is more than one line (not sure if this was intentional).

@RickStrahl
Copy link
Contributor

FWIW - I normalize my linefeeds to LF before sending to Markdig, so that's not the issue I'm seeing...

@MihaZupan
Copy link
Collaborator

I suspect that your case hit this

And it doesn't match the table if the text before it is more than one line (not sure if this was intentional).

Should be fixed with #905 to allow multiple lines of text to precede the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants